package de.szut.gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTree;
import javax.swing.JTable;
import javax.swing.border.BevelBorder;
import javax.swing.JTextField;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JToolBar;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.BoxLayout;
import javax.swing.JSplitPane;
import javax.swing.JScrollPane;
import javax.swing.table.DefaultTableModel;

public class Frame extends JFrame {

	private static final long serialVersionUID = 5070681280832126736L;
	private JPanel contentPane;
	private JTextField selectInput;
	private JTextField lowerLimitInput;
	private JTextField upperLimitInput;
	private JTable table;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Frame frame = new Frame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Frame() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		
		JMenu fileMenu = new JMenu("File");
		menuBar.add(fileMenu);
		
		JMenu editMenu = new JMenu("Edit");
		menuBar.add(editMenu);
		
		JMenu helpMenu = new JMenu("Help");
		menuBar.add(helpMenu);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(5, 0));
		setContentPane(contentPane);
		
		JSplitPane splitPane = new JSplitPane();
		splitPane.setDividerSize(3);
		splitPane.setResizeWeight(0.25);
		contentPane.add(splitPane, BorderLayout.CENTER);
		
		JTree tree = new JTree();
		tree.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
		
		JScrollPane treeScrollPane = new JScrollPane(tree);
		splitPane.setLeftComponent(treeScrollPane);
		
		JToolBar toolBar = new JToolBar();
		toolBar.setFloatable(false);
		contentPane.add(toolBar, BorderLayout.NORTH);
		
		JButton demoButton = new JButton("Demo");
		toolBar.add(demoButton);
		
		JPanel footerPane = new JPanel();
		contentPane.add(footerPane, BorderLayout.SOUTH);
		footerPane.setLayout(new BorderLayout(0, 0));
		
		JLabel statusLabel = new JLabel("MyDB loaded");
		footerPane.add(statusLabel, BorderLayout.EAST);
		
		JPanel dataPane = new JPanel();
		splitPane.setRightComponent(dataPane);
		dataPane.setLayout(new BorderLayout(0, 0));
		
		JPanel limitPane = new JPanel();
		dataPane.add(limitPane, BorderLayout.SOUTH);
		limitPane.setLayout(new BorderLayout(0, 0));
		
		JCheckBox limitCheckbox = new JCheckBox("Limit");
		limitPane.add(limitCheckbox, BorderLayout.WEST);
		
		JPanel limitRangePane = new JPanel();
		limitPane.add(limitRangePane, BorderLayout.CENTER);
		limitRangePane.setLayout(new BoxLayout(limitRangePane, BoxLayout.X_AXIS));
		
		lowerLimitInput = new JTextField();
		lowerLimitInput.setText("von");
		limitRangePane.add(lowerLimitInput);
		lowerLimitInput.setColumns(10);
		
		upperLimitInput = new JTextField();
		upperLimitInput.setText("bis");
		limitRangePane.add(upperLimitInput);
		upperLimitInput.setColumns(10);
		
		JPanel displayPane = new JPanel();
		dataPane.add(displayPane, BorderLayout.CENTER);
		displayPane.setLayout(new BorderLayout(0, 5));
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
			},
			new String[] {
				"New column", "New column", "New column", "New column", "New column"
			}
		));
		table.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
		
		JScrollPane tableScrollPane = new JScrollPane(table);
		displayPane.add(tableScrollPane, BorderLayout.CENTER);
		
		selectInput = new JTextField();
		displayPane.add(selectInput, BorderLayout.NORTH);
		selectInput.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
		selectInput.setColumns(10);
	}

}
